package com.ruoyi.pingjiao.service.impl;

import com.ruoyi.pingjiao.domain.CourseclassMetaclass;
import com.ruoyi.pingjiao.mapper.CourseclassMetaclassMapper;
import com.ruoyi.pingjiao.service.ICourseclassMetaclassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 行政班级上课Service业务层处理
 * 
 * @author 牛亚博
 * @date 2023-07-10
 */
@Service
public class CourseclassMetaclassServiceImpl implements ICourseclassMetaclassService
{
    @Autowired
    private CourseclassMetaclassMapper courseclassMetaclassMapper;

    /**
     * 查询行政班级上课
     * 
     * @param courseclassId 行政班级上课主键
     * @return 行政班级上课
     */
    @Override
    public CourseclassMetaclass selectCourseclassMetaclassByCourseclassId(Long courseclassId)
    {
        return courseclassMetaclassMapper.selectCourseclassMetaclassByCourseclassId(courseclassId);
    }

    /**
     * 查询行政班级上课列表
     * 
     * @param courseclassMetaclass 行政班级上课
     * @return 行政班级上课
     */
    @Override
    public List<CourseclassMetaclass> selectCourseclassMetaclassList(CourseclassMetaclass courseclassMetaclass)
    {
        return courseclassMetaclassMapper.selectCourseclassMetaclassList(courseclassMetaclass);
    }

    /**
     * 新增行政班级上课
     * 
     * @param courseclassMetaclass 行政班级上课
     * @return 结果
     */
    @Override
    public int insertCourseclassMetaclass(CourseclassMetaclass courseclassMetaclass)
    {
        return courseclassMetaclassMapper.insertCourseclassMetaclass(courseclassMetaclass);
    }

    /**
     * 修改行政班级上课
     * 
     * @param courseclassMetaclass 行政班级上课
     * @return 结果
     */
    @Override
    public int updateCourseclassMetaclass(CourseclassMetaclass courseclassMetaclass)
    {
        int a = courseclassMetaclassMapper.updateCourseclassMetaclass(courseclassMetaclass);
        if(a == 0){
            return this.insertCourseclassMetaclass(courseclassMetaclass);
        }else{
            return a;
        }
//        return courseclassMetaclassMapper.updateCourseclassMetaclass(courseclassMetaclass);
    }

    /**
     * 批量删除行政班级上课
     * 
     * @param courseclassIds 需要删除的行政班级上课主键
     * @return 结果
     */
    @Override
    public int deleteCourseclassMetaclassByCourseclassIds(Long[] courseclassIds)
    {
        return courseclassMetaclassMapper.deleteCourseclassMetaclassByCourseclassIds(courseclassIds);
    }

    /**
     * 删除行政班级上课信息
     * 
     * @param courseclassId 行政班级上课主键
     * @return 结果
     */
    @Override
    public int deleteCourseclassMetaclassByCourseclassId(Long courseclassId,Long metaclassId)
    {
        return courseclassMetaclassMapper.deleteCourseclassMetaclassByCourseclassId(courseclassId,metaclassId);
    }

    @Override
    public int addCourseclassMetaclass(Long courseclassId, Long[] metaclassId) {
        Map<String,Object>map=new HashMap<>();
        map.put("courseclassId",courseclassId);
        map.put("metaclassId",metaclassId);
        return courseclassMetaclassMapper.addCourseclassMetaclass(map);
    }

}
